package com.jws.jawestshow;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.jws.thirdlibrary.CxManager;

public class LEDActivity extends Activity {

    private Button mButtonOpen;
    private Button mButtonClose;
    private CxManager mCxManager = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_led);
        mCxManager = CxManager.create(this);
        initButton();
    }

    private void initButton() {
        mButtonOpen = (Button) findViewById(R.id.open);
        mButtonClose = (Button) findViewById(R.id.close);

        mButtonOpen.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mCxManager.jwsOpenLED();
                Toast.makeText(LEDActivity.this, R.string.jws_open_success, Toast.LENGTH_SHORT).show();
            }
        });

        mButtonClose.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mCxManager.jwsCloseLED();
                mCxManager.jwsCloseTheDoor();
                Toast.makeText(LEDActivity.this, R.string.jws_close_success, Toast.LENGTH_SHORT).show();
            }
        });

    }
}
